*REPLICATION DO-FILE FOR *
*JOHN M. CAREY *
*"Malapportionment and Ideological Bias in Chilean Electoral Districts"*
* LATIN AMERICAN POLITICS & SOCIETY 2016*

*The data wrangling involves merging, cleaning, and configuring data from over 20 *
*raw data files downloaded from Chile's Servicio Nacional Electoral as well as *
*from the Obsrvatorio Politico Electoral from the Universidad Diego Portales *
*and from Chilean colleagues.  For those data files and/or for the Stata code *
*to merge and configure them, please contact the author at john.carey@dartmouth.edu*

*The following code uses data files for each congressional district configuration*
*analyzed in the article:  *
*	-- pre-reform Chamber districts *
*   -- post-reform Chamber districts *
*   -- pre-reform Senate districts *
*   -- post-reform Senate districts *
* and produces the graphs presented in the article.*




*Pre-reform Chamber districts*
use "LAPS replication data & code/CAREY_LAPS_2016_Chamber_Binominal_Leftism_by_Pres_2nd_Round_Elecs.dta", replace

*FIGURE 2A*
twoway (lfitci dist_left_avg pop_per_seat) ///
	(scatter dist_left_avg pop_per_seat, sort ///
	msymbol(none) mlabel(distrito) mlabsize(vsmall)), ///
	ytitle(District Leftism) xtitle(Population Per Chamber Seat) ///
	title(Leftism by Apportionment) ///
	subtitle(Binominal Chamber Districts) ///
	caption(Population data from 2002 census) legend(off)

*Post-reform Chamber districts*
use "LAPS replication data & code/CAREY_LAPS_2016_Chamber_Post-Reform_Leftism_by_Pres_2nd_Round_Elecs.dta", replace

*FIGURE 3A*
twoway (lfitci new_dist_left_avg pop_per_seat) ///
	(scatter new_dist_left_avg pop_per_seat, sort ///
	msymbol(none) mlabel(new_dist) mlabsize(vsmall)), ///
	ytitle(District Leftism) xtitle(Population Per Chamber Seat) ///
	title(Leftism by Apportionment) ///
	subtitle(Post-Reform Chamber Districts) ///
	caption(Population data from 2012 census) legend(off)


*FIGURE 1A*
twoway (scatter dist_mag censo_2012) ///
	, ytitle(District Magnitude) xtitle(Population - 2012 Census) xmtick(##5) legend(off) ///
	title(Number of Seats by Population - New Chilean Chamber)

	
*Pre-reform Senate districts*
use "LAPS replication data & code/CAREY_LAPS_2016_Senate_Binominal_Leftism_by_Pres_2nd_Round_Elecs.dta", replace

*FIGURE 2B*
twoway (lfitci sen_left_avg voter_per_seat) ///
	(scatter sen_left_avg voter_per_seat, sort ///
	msymbol(none) mlabel(circsenatorial) mlabsize(vsmall)), ///
	ytitle(District Leftism) xtitle(Voters Per Senate Seat) ///
	title(Leftism by Apportionment) ///
	subtitle(Binominal Senate Districts) ///
	caption(Voters per seat from Elections of 2001 and 2005) legend(off)

*Post-reform Senate districts*
use "LAPS replication data & code/CAREY_LAPS_2016_Senate_Post-Reform_Leftism_by_Pres_2nd_Round_Elecs.dta", replace

*FIGURE 3B*
twoway (lfitci new_sen_left_avg pop_per_seat) ///
	(scatter new_sen_left_avg pop_per_seat, sort ///
	msymbol(none) mlabel(new_sen) mlabsize(vsmall)), ///
	ytitle(District Leftism) xtitle(Population Per Senate Seat) ///
	title(Leftism by Apportionment) ///
	subtitle(Post-Reform Senate Districts) ///
	caption(Population data from 2012 census) legend(off)

*FIGURE 1B*
twoway (scatter dist_mag censo_2012, sort msize(small)) ///
	, ytitle(District Magnitude) xtitle(Population 2012) xlabel(, format(%9.0f)) legend(off) ///
	title(Seats by Population - Post-Reform Chilean Senate)	
